﻿var ismanager = 0;
// 读取列表
$(document).ready(function() {
    var deptid = LexunJS.GetQueryString("deptid");
    var startday = LexunJS.GetQueryString("startday");
    var endday = LexunJS.GetQueryString("endday");

    if (deptid > 0)
        $("#utxdeptid").val(deptid);
    if (startday != "")
        $("#iStartDay").val(startday);
    if (endday != "")
        $("#iEndDay").val(endday);

    //showList();
});

function Search() {
    var deptId = $("#utxdeptid").val();                                 // 部门ID           
    var addDate1 = $("#iStartDay").val();                               // 日期
    var addDate2 = $("#iEndDay").val();                                 // 日期
    var isContainsSelf = 1;       // isContainsSelf 查询下级子部门时,是否包括自己 1不包括
    $("#divList").html("<img src=\"../images/loading.gif\" />");        // 清空列表
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerReport.ashx',
        data: 'act=dept_list&isContainsSelf=' + isContainsSelf + '&deptId=' + deptId + '&addDate1=' + escape(addDate1) + '&addDate2=' + escape(addDate2),
        timeout: '30000',
        error: function() {
            //alert("系统繁忙,请稍候后试！");
        }, success: function(json) {
        charlist();
            //showListCallBack(json);
           
        }
    });

    //showReprot(1);
}



function showList() {
    var deptId = $("#utxdeptid").val();                                 // 部门ID           
    var addDate1 = $("#iStartDay").val();                               // 日期
    var addDate2 = $("#iEndDay").val();                                 // 日期
    var isContainsSelf = LexunJS.GetQueryString("isContainsSelf");      // isContainsSelf 查询下级子部门时,是否包括自己 1不包括
    $("#divList").html("<img src=\"../images/loading.gif\" />");        // 清空列表 
    $.ajax({
        type: 'POST',
        url: '../Handler/HandlerReport.ashx',
        data: 'act=dept_list&isContainsSelf=' + isContainsSelf + '&deptId=' + deptId + '&addDate1=' + escape(addDate1) + '&addDate2=' + escape(addDate2),
        timeout: '30000',
        error: function() {
            alert("系统繁忙,请稍候后试！");
        }, success: function(json) {
        charlist();
        showListCallBack(json);
       
        }
    });

    //showReprot(1);
    
}

function charlist() {
    var deptId = $("#utxdeptid").val();                                 // 部门ID           
    var addDate1 = $("#iStartDay").val();                               // 日期
    var addDate2 = $("#iEndDay").val();                                 // 日期
    $("#diccharttoday").html("<img src=\"../images/loading.gif\" />");        // 清空列表

    $.ajax({
        type: "POST",
        url: "../Quantify/AjaxServer.aspx",
        dataType: 'json',
        data: "alt=divcharlist&deptid=" + deptId + "&statrday=" + addDate1 + "&endday=" + addDate2 + "",
        processData: false,
        timeout: '30000',
        success: function(msg) {
        divcharlist(msg, msg.deptid, addDate1, addDate2);
        },
        error: function() {

            document.getElementById('diccharttoday').innerHTML = "系统繁忙";

        }

    });
}
function divcharlist(msg, deptid, addDate1, addDate2) {
    var yesdaychart = "";
  
    if (msg.msg.length > 0) {
        yesdaychart = "[";
        for (var i = 0; i < msg.msg.length; i++) {

            yesdaychart += "{name: '" + msg.msg[i].basisname + msg.msg[i].actual_number + "', y: " + msg.msg[i].actual_goal + ",dataLabels:'" + GetUrl(msg.msg[i].basisname) + "&deptid=" + deptid + "&addDate2=" + addDate2 + "" + "&addDate1=" + addDate1 + "'},";
        }
        yesdaychart = yesdaychart.substring(0, yesdaychart.length - 1);
        yesdaychart += "]";
        yesdaychart = eval('' + yesdaychart + '');

        chartxsDeptlist(yesdaychart, '工作', 'diccharttoday', ismanager);
    }
    else {
        $("#diccharttoday").html("");        // 清空列表
    }
}

// 打开报表 -- 1 hfollow盘源跟进 2 cfollow客源跟进 3 look待看提醒 4 looked已带看(售) 16 mark3已带看(租) 5 newhousing新增盘(售) 14 mark1新增盘(租) 
// 6 newcustomer新增客(买) 15 mark2新增客(租) 17 mark4新转客(买) 18 mark5新转客(租) 7 only独家 8 versa反签 9 key钥匙 
// 10 telphone查看电话 11 hasphoto上传图片盘源 12 photo上传图片数 13 self自看房源  
function showReprot(typeid) {
    var deptId = $("#utxdeptid").val();             // 部门ID           
    var addDate1 = $("#iStartDay").val();           // 日期
    var addDate2 = $("#iEndDay").val();             // 日期
    var isContainsSelf = 1;      // isContainsSelf 查询下级子部门时,是否包括自己 1不包括
    document.getElementById("reportsDetail").src = "../Reports/ReportPages/DeptList_Page.aspx?typeid=" + typeid + "&deptid=" + deptId + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&isContainsSelf=" + isContainsSelf;
}

/*
功能: 将返回的json数据进行排版
json: json数据        
*/
function showListCallBack(response) {
    var json = eval("(" + response + ")");
    var record = json.record;
   
    if (record == null || record.length == 0) {
        $("#divList").html("<font color='red'>&nbsp;系统内暂无您查询的信息!</font>");
        return;
    }
    var page = json.page;

    ismanager = page.ismanager; // 0当前用户非查询部门管理者 1当前用户是查询部门管理者

    var arr = [];
    arr.push("<table id='table1' width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='#a8c7ce'>");
    arr.push("<tr>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("部门");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(1)\" title=\"查看盘源跟进图形报表\" >盘源跟进</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(2)\" title=\"查看客源跟进图形报表\" >客源跟进</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(3)\" title=\"查看待看提醒图形报表\" >待看提醒</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(4)\" title=\"查看已带看售盘图形报表\" >已带看(售)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(16)\" title=\"查看已带看租盘图形报表\" >已带看(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(5)\" title=\"查看新添盘源图形报表\" >新增盘(售)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(14)\" title=\"查看新添盘源图形报表\" >新增盘(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(6)\" title=\"查看新添买客图形报表\" >新增客(买)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(15)\" title=\"查看新添租客图形报表\" >新增客(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(17)\" title=\"查看新转买客图形报表\" >新转客(买)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(18)\" title=\"查看新转租客图形报表\" >新转客(租)</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(7)\" title=\"查看独家图形报表\" >独家</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(8)\" title=\"查看反签图形报表\" >反签</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(9)\" title=\"查看钥匙图形报表\" >钥匙</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(10)\" title=\"查看电话图形报表\" >查看电话</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(11)\" title=\"查看上传图片盘源图形报表\" >上传图片盘源</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(12)\" title=\"查看上传图片数图形报表\" >上传图片数</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(13)\" title=\"查看自看房源图形报表\" >自看房源</a>");
    arr.push("</td>");


    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(19)\" title=\"查看家访图形报表\" >家访</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(21)\" title=\"查看诚意金图形报表\" >诚意金</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(22)\" title=\"查看摆台图形报表\" >摆台</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a href=\"javascript:showReprot(23)\" title=\"查看售后服务图形报表\" >售后服务</a>");
    arr.push("</td>");
    arr.push("<td height='25' bgcolor='d3eaef' class='STYLE10'>");
    arr.push("<a  >总分</a>");
    arr.push("</td>");
    
    arr.push("</tr>");

    var total_hfollow = 0;
    var total_cfollow = 0;
    var total_look = 0;
    var total_looked = 0;
    var total_newhousing = 0;
    var total_newcustomer = 0;
    var total_only = 0;
    var total_versa = 0;
    var total_key = 0;
    var total_telphone = 0;
    var total_hasphoto = 0;
    var total_photo = 0;
    var total_self = 0;
    var total_mark1 = 0;    // 租盘
    var total_mark2 = 0;    // 租客
    var total_mark3 = 0;    // 已带看(租)
    var total_mark4 = 0;    // 新转客(买)
    var total_mark5 = 0;    // 新转客(租)
    var actual = 0;//量化总分
    //19 家访visit  21诚意金EarnestMoney  22摆台talks  23 售后服务afterservice

    var total_visit = 0;
    var total_EarnestMoney = 0;
    var total_talks = 0;
    var total_afterservice = 0;
    
    var addDate1 = $("#iStartDay").val();           // 日期
    var addDate2 = $("#iEndDay").val();             // 日期
    var recordLength = record.length;
    for (var i = 0; i < recordLength; i++) {
        total_hfollow += parseInt(record[i].hfollow);
        total_cfollow += parseInt(record[i].cfollow);
        total_look += parseInt(record[i].look);
        total_looked += parseInt(record[i].looked);
        total_newhousing += parseInt(record[i].newhousing);
        total_newcustomer += parseInt(record[i].newcustomer);
        total_only += parseInt(record[i].only);
        total_versa += parseInt(record[i].versa);
        total_key += parseInt(record[i].key);
        total_telphone += parseInt(record[i].telphone);
        total_hasphoto += parseInt(record[i].hasphoto);
        total_photo += parseInt(record[i].photo);
        total_self += parseInt(record[i].self);
        total_mark1 += parseInt(record[i].mark1);
        total_mark2 += parseInt(record[i].mark2);
        total_mark3 += parseInt(record[i].mark3);
        total_mark4 += parseInt(record[i].mark4);
        total_mark5 += parseInt(record[i].mark5);
        total_visit += parseInt(record[i].visit);
        total_EarnestMoney += parseInt(record[i].earnestmoney);
        total_talks += parseInt(record[i].talks);
        total_afterservice += parseInt(record[i].afterservice);
        actual+=parseInt(record[i].actual_goal)
        if (i % 2 == 0)
            arr.push("<tr id='tr_" + i + "' bgcolor='#FFFFFF' style='cursor: pointer;'  onclick=\"selectedTr('" + i + "')\" >");
        else 
            arr.push("<tr id='tr_" + i + "' bgcolor='#EEEDED' style='cursor: pointer;'  onclick=\"selectedTr('" + i + "')\" >");

        arr.push("<td height='20' class='STYLE6'>");
        if (record[i].typename == "分行")
            arr.push("<a title=\"该部门下所有人员的量化详情\" href=\"javascript:goTo('" + record[i].deptid + "','" + record[i].dept + "','" + ismanager + "')\">" + record[i].dept + "</a></td>");
        else
            arr.push("<a href=\"javascript:goToMe('" + record[i].deptid + "','" + record[i].dept + "')\">" + record[i].dept + "</a></td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].hfollow) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(1,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看盘源跟进详情\" >" + record[i].hfollow + "</a></td>");
        else
            arr.push("" + record[i].hfollow + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].cfollow) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(2,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看客源跟进详情\" >" + record[i].cfollow + "</a></td>");
        else
            arr.push("" + record[i].cfollow + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].look) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(3,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看待看提醒详情\" >" + record[i].look + "</a></td>");
        else
            arr.push("" + record[i].look + "</td>");
    
        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].looked) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(4,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看已带看售盘详情\" >" + record[i].looked + "</a></td>");
        else
            arr.push("" + record[i].looked + "</td>");
            
        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark3) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(16,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看已带看租盘详情\" >" + record[i].mark3 + "</a></td>");
        else
            arr.push("" + record[i].mark3 + "</td>");
        
        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].newhousing) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(5,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添售盘详情\" >" + record[i].newhousing + "</a></td>");
        else
            arr.push("" + record[i].newhousing + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark1) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(14,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添租盘详情\" >" + record[i].mark1 + "</a></td>");
        else
            arr.push("" + record[i].mark1 + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].newcustomer) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(7,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添买客源详情\" >" + record[i].newcustomer + "</a></td>");
        else
            arr.push("" + record[i].newcustomer + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark2) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(15,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新添租客源详情\" >" + record[i].mark2 + "</a></td>");
        else
            arr.push("" + record[i].mark2 + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark4) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(17,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新转买客源详情\" >" + record[i].mark4 + "</a></td>");
        else
            arr.push("" + record[i].mark4 + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].mark5) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(18,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看新转租客源详情\" >" + record[i].mark5 + "</a></td>");
        else
            arr.push("" + record[i].mark5 + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].only) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(8,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看独家详情\" >" + record[i].only + "</a></td>");
        else
            arr.push("" + record[i].only + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].versa) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail('9','" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看反签详情\" >" + record[i].versa + "</a></td>");
        else
            arr.push("" + record[i].versa + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].key) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(20,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看钥匙详情\" >" + record[i].key + "</a></td>");
        else
            arr.push("" + record[i].key + "</td>");

        arr.push("<td height='20' class='STYLE6'>");
        if (parseInt(record[i].telphone) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(10,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看电话详情\" >" + record[i].telphone + "</a></td>");
        else
            arr.push("" + record[i].telphone + "</td>");
            
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].hasphoto + "</td>");
        arr.push("<td height='20' class='STYLE6'>");
        arr.push("" + record[i].photo + "</td>");
        arr.push("<td height='20' class='STYLE6'>");       
        if (parseInt(record[i].self) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(12,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看自看房详情\" >" + record[i].self + "</a></td>");
        else
            arr.push("" + record[i].self + "</td>");


        //19 家访visit  21诚意金EarnestMoney  22摆台talks  23 售后服务afterservice

        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].visit) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(21,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看家访房源详情\" >" + record[i].visit + "</a></td>");
        else
            arr.push("" + record[i].visit + "</td>");



        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].earnestmoney) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(22,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看诚意金详情\" >" + record[i].earnestmoney + "</a></td>");
        else
            arr.push("" + record[i].earnestmoney + "</td>");



        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].talks) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(23,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看摆台详情\" >" + record[i].talks + "</a></td>");
        else
            arr.push("" + record[i].talks + "</td>");



        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].afterservice) > 0 && ismanager == 1)
            arr.push("<a href=\"javascript:goToDetail(24,'" + record[i].deptid + "','" + escape(addDate1) + "','" + escape(addDate2) + "')\" title=\"查看售后服务详情\" >" + record[i].afterservice + "</a></td>");
        else
            arr.push("" + record[i].afterservice + "</td>");
            
        arr.push("<td height='20' class='STYLE6'>");

        if (parseInt(record[i].actual_goal) > 0 && ismanager == 1)
            arr.push("<a  >" + record[i].actual_goal + "</a></td>");
        else
            arr.push("" + record[i].actual_goal + "</td>");    
    }

    // 底部总计
    arr.push("<tr bgcolor='#FFF6FF'>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>总计：</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_hfollow + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_cfollow + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_look + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_looked + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark3 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_newhousing + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark1 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_newcustomer + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark2 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark4 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_mark5 + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_only + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_versa + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_key + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_telphone + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_hasphoto + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_photo + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_self + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_visit + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_EarnestMoney + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_talks + "</b>");
    arr.push("</td>");

    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + total_afterservice + "</b>");
    arr.push("</td>");
    arr.push("<td height='20' class='STYLE6'>");
    arr.push("<b>" + actual + "</b>");
    arr.push("</td>");
    arr.push("</tr>");

    arr.push("</table>");

    $("#divList").html(arr.join('')); // 显示列表
}

// 选中某行
function selectedTr(id) {
    $("tr").removeClass("selected");
    $("#tr_" + id).addClass("selected");

    return false;
}

// 响应键盘查询
function responseEnter(e) {
    var key = window.event ? e.keyCode : e.which;
    if (key == 13)
        search();
}

// 查看部门个人总量
function goTo(deptid, deptname, ismanager) {
    var startDay = $("#iStartDay").val();
    var endDay = $("#iEndDay").val();

    var url = "../AM/DeptUserList.aspx?ismanager=" + ismanager + "&deptid=" + deptid + "&deptname=" + escape(deptname) + "&startday=" + escape(startDay) + "&endday=" + escape(endDay);

    self.parent.closeTab('个人量化');
    self.parent.addTab('个人量化', url, 'icon-nav');
}

// 查看下级子部门
function goToMe(deptid, deptname) {
    var startDay = $("#iStartDay").val();
    var endDay = $("#iEndDay").val();

    // isContainsSelf 查询下级子部门时,是否包括自己 1不包括
    var url = "../AM/DeptList.aspx?isContainsSelf=1&deptid=" + deptid + "&deptname=" + escape(deptname) + "&startday=" + escape(startDay) + "&endday=" + escape(endDay);
    self.parent.addTab(deptname, url, 'icon-nav');
}

// 查看详情
function goToDetail(typeid, deptid, addDate1, addDate2) {
    var title = "";
    var url = "";

    if (typeid == 1) {
        title = "盘源跟进信息";
        url = "../AM/HousingFollowList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&flwtype=1";
    }
    else if (typeid == 2) {
        title = "客源跟进信息";
        url = "../AM/CustomerFollowList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 3) {
        title = "待看提醒";
        url = "../AM/CustomerAlertList.aspx?ftype=" + escape("约看") + "&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 4) {
        title = "带看房(售)";
        url = "../Quantify/Report/lp_ForSale.aspx?ftype=" + escape("带看房") + "&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 16) {
        title = "带看房(租)";
        url = "../Quantify/Report/lp_ForSale.aspx?ftype=" + escape("带看房") + "&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 5) {
        title = "新添售盘";
        url = "../AM/Housing_List.aspx?reporttypeid=11&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 14) {
        title = "新添租盘";
        url = "../AM/Housing_List.aspx?reporttypeid=14&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 7) {
        title = "新添买客";
        url = "../AM/Customer_List.aspx?reporttypeid=1&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 15) {
        title = "新添租客";
        url = "../AM/Customer_List.aspx?reporttypeid=2&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 17) {
        title = "新转买客";
        url = "../AM/Customer_List.aspx?reporttypeid=17&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 18) {
        title = "新转租客";
        url = "../AM/Customer_List.aspx?reporttypeid=18&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 8) {
        title = "独家";
        url = "../AM/Housing_List.aspx?reporttypeid=12&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 9) {
        title = "反签";
        url = "../AM/Housing_List.aspx?reporttypeid=13&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 10) {
        title = "查看电话";
        url = "../AM/TelList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);
    }
    else if (typeid == 12) {
        title = "自看房";
        url = "../AM/HousingFollowList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&flwtype=2";
    }
    else if (typeid == 20) {
        title = "钥匙";
        url = "../AM/Housing_List.aspx?reporttypeid=20&deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2);

    }
    else if (typeid == 21) {
        title = "家访";
        url = "../AM/HousingFollowList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&flwtype=21";

    } else if (typeid == 22) {
        title = "诚意金";
        url = "../AM/CustomerFollowList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&ftype=" + escape('诚意金');

    }
    else if (typeid == 23) {
        title = "摆台";
        url = "../AM/CustomerFollowList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&ftype=" + escape('摆台');

    } else if (typeid == 24) {
        title = "售后服务";
        url = "../AM/CustomerFollowList.aspx?deptid=" + deptid + "&addDate1=" + escape(addDate1) + "&addDate2=" + escape(addDate2) + "&ftype=" + escape('成交后服务');
    }

    self.parent.closeTab(title);
    self.parent.addTab(title, url, 'icon-nav');
}